var timoutid;
$(document).ready(function(){
	$("#tabsecond li").each(function(index){
		$(this).click(function(){
			$("#tabsecond li.tabin").removeClass("tabin");
			$(this).addClass("tabin");
			var user = $(this).html();
			document.getElementById("users").value = user;
			$.post("/chat/mes_reqUser.action",{uname:encodeURIComponent(user)}, function(html){
				    document.getElementById("realcontent").innerHTML = decodeURIComponent(html);
			  });
		});
	});
	//对于loading图片绑定ajax请求开始和交互结束的事件
	$("#contentsecond img").bind("ajaxStart",function(){
		//把div里面的内容清空
		$("#realcontent").html("");
		//$(this).show();
	}).bind("ajaxStop",function(){
		document.getElementById('realcontent').scrollTop=document.getElementById('realcontent').scrollHeight;
	});
});
function sub(){
	var user = document.getElementById("users").value;
   //	var rcontext = document.getElementById("rcontext").value;
   	var rcontext = $("#rcontext").val();
   	if (rcontext=="") {alert('发送的信息内容不能为空');return}
	if (rcontext.substring(0,1)==" ") {alert('发送的信息首字符不能为空格哦~');return}
   	document.getElementById("rcontext").value = "";
   	var sname = $("#sname").val();
   	if(rcontext != ""){
  		$.post("/chat/mes_show.action",{yname:encodeURIComponent(sname),replyMessage:encodeURIComponent(rcontext),uname:encodeURIComponent(user)},function(d){
  			$.post("/chat/mes_reqUser.action",{uname:encodeURIComponent(user)}, function(html){
				    $("#realcontent").html(html);
			  }); 
  		});
  	}
}